

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:ysy_flutter_mvvm_yuanxuan/bean/subitorder/SubitOrderEntity.dart';
import 'package:ysy_flutter_mvvm_yuanxuan/event/ToBottomNavigationBarIndex.dart';
import 'package:ysy_flutter_mvvm_yuanxuan/view/AppMain.dart';
import 'package:ysy_flutter_mvvm_yuanxuan/view/cartshoppingwidget/CartListWidget.dart';
import 'package:ysy_flutter_mvvm_yuanxuan/view/goods_details/GoodsDetails.dart';
import 'package:ysy_flutter_mvvm_yuanxuan/view/order/OrderWidget.dart';
import 'package:ysy_flutter_mvvm_yuanxuan/view/subit_order/SubitOrderWidget.dart';

//返回app主页 并切换 主页tab
void backAppMainAndTab(BuildContext context,int index){
  backAppMain(context);
  eventBus.fire(ToBottomNavigationBarIndex(index));
}

//返回app主页
void backAppMain(BuildContext context){
  Navigator.of(context).popUntil(ModalRoute.withName("AppMain"));
}

//去app主页
void toAppMain(BuildContext context){
  Navigator.of(context).pushNamed("AppMain");
}

void toLoginWidget(BuildContext context){
  Navigator.of(context).pushNamed("login");
}

//去订单
void toOrderWidget(BuildContext context){
  Navigator.of(context).pushNamed("OrderWidget");
  // Navigator.of(context).push(MaterialPageRoute(builder: (BuildContext context) {
  //   return OrderWidget();
  // }));
}

//去商品详情
void toGoodsDetails(BuildContext context,String id){
  Navigator.of(context).pushNamed("goodsdetails",arguments: {"goodsDetailsID":id});
  // Navigator.of(context).push(MaterialPageRoute(builder: (BuildContext context) {
  //   return GoodsDetails();
  // },settings:RouteSettings(name:"goodsdetails",arguments: {"goodsDetailsID":id}) ),);
}

//商品详情 获取传参
String? getGoodsDetailsArguments(BuildContext context){
  Map<String,String> arguments = ModalRoute.of(context)?.settings.arguments as Map<String,String>;
  return arguments["goodsDetailsID"];
}

//去购物车
void toCartList(BuildContext context){
  Navigator.of(context).pushNamed("CartListWidget");
  // Navigator.of(context).push(MaterialPageRoute(builder: (BuildContext context) {
  //   return CartListWidget();
  // },));
}


//去确认订单
void toSubitOrder(BuildContext context,List<SubitOrderEntity> entitys){
  Navigator.of(context).pushNamed("SubitOrderWidget",arguments: entitys);
  // Navigator.of(context).push(MaterialPageRoute(builder: (BuildContext context) {
  //   return SubitOrderWidget();
  // },settings:RouteSettings(name:"SubitOrderEntity",arguments: entitys) ),);
}

//确认订单 获取传参
List<SubitOrderEntity>? getSubitOrderArguments(BuildContext context){
  return ModalRoute.of(context)?.settings.arguments as List<SubitOrderEntity>;
}